package com.clear.bridge;

import com.clear.bridge.abstractor.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // 先创建一个驱动实例：我们可以通过反射来构建
        Driver driver = (Driver) Class
                .forName("com.clear.bridge.implementor.MySQLDriver").newInstance();
        // 注册给DriverManager
        DriverManager driverManager = new DriverManagerOne(driver);

        // 获取连接
        Connection connection = driverManager.getConnection();
        System.out.println(connection);

        // =====================================================================================
        Driver driver2 = (Driver) Class
                .forName("com.clear.bridge.implementor.OracleDriver").newInstance();
        DriverManagerOne driverManager2 = new DriverManagerOne(driver2);
        Connection connection2 = driverManager2.getConnection();
        System.out.println(connection2);

        // ====================================================================================
        Driver driver3 = (Driver) Class
                .forName("com.clear.bridge.implementor.MySQLDriver").newInstance();
        DriverManagerTwo driverManager3 = new DriverManagerTwo(driver3);
        Connection connection3 = driverManager3.getConnection();
        System.out.println(connection3);

        // ====================================================================================
        Driver driver4 = (Driver) Class
                .forName("com.clear.bridge.implementor.OracleDriver").newInstance();
        DriverManagerTwo driverManager4 = new DriverManagerTwo(driver4);
        Connection connection4 = driverManager4.getConnection();
        System.out.println(connection4);
    }
}
